<?php
/**
 * Unfuddle Notebook Model
 *
 * @package     Unfuddle
 * @subpackage  Data Models
 * @author      Luke Visinoni <luke.visinoni@gmail.com>
 * @copyright   (c) 2010 Luke Visinoni <luke.visinoni@gmail.com>
 * @version     $Id: Notebook.php 29 2011-05-09 07:08:53Z luke.visinoni $
 */
class Unfuddle_Model_Notebook extends Unfuddle_Model_Abstract {

    /**
     * Returns a collection of notebooks
     */
    const URI_NOTEBOOKS = '/notebooks';
    
    /**
     * Returns a collection of notebooks for the given project
     */
    const URI_PROJECT_NOTEBOOKS = '/projects/%d/notebooks';
    
    /**
     * Returns a collection of notebooks for the given project
     * @todo Make sure all of the "by id" constants are consistently named
     */
    const URI_NOTEBOOK_BY_ID = '/projects/%d/notebooks/%d';
    
    /**
     * Returns a collection of pages for the given project
     */
    const URI_PROJECT_NOTEBOOK_PAGES = '/projects/%d/notebooks/%d/pages';
    
    /**
     * Access a page by title
     */
    const URI_PROJECT_NOTEBOOK_PAGE_BY_TITLE = '/projects/%d/notebooks/%d/pages/by_title/%s';
    
    /**
     * Returns latest versions of all pages within the notebook
     */
    const URI_PROJECT_NOTEBOOK_PAGE_UNIQUE = '/projects/%d/notebooks/%d/pages/unique';
    
    /**
     * Access page by project, notebook, and page id
     */
    const URI_PROJECT_NOTEBOOK_PAGE_BY_ID = '/projects/%d/notebooks/%d/pages/%d';
    
    /**
     * First version of a page
     */
    const URI_PROJECT_NOTEBOOK_PAGE_ROOT = '/projects/%d/notebooks/%d/pages/%d/root';
    
    /**
     * Latest version of a page
     */
    const URI_PROJECT_NOTEBOOK_PAGE_LATEST = '/projects/%d/notebooks/%d/pages/%d/latest';
    
    /**
     * Returns list of versions of a page
     */
    const URI_PROJECT_NOTEBOOK_PAGE_VERSIONS = '/projects/%d/notebooks/%d/pages/%d/versions';
    
    /**
     * Compare two versions
     */
    const URI_PROJECT_NOTEBOOK_PAGES_COMPARE = '/projects/%d/notebooks/%d/pages/%d/compare';
    
    /**
     * @var string Model name
     */
    protected $_name = 'notebook';
    
    /**
     * @var array Model fields
     */
    protected $_fields = array (
        'created-at' => array('type' => 'datetime', 'required' => false, 'read-only' => true),
        'default-page-id' => array('type' => 'integer', 'required' => false, 'read-only' => false),
        'id' => array('type' => 'integer', 'required' => false, 'read-only' => true),
        'project-id' => array('type' => 'integer', 'required' => false, 'read-only' => true),
        'title' => array('type' => 'text', 'required' => false, 'read-only' => false),
        'updated-at' => array('type' => 'datetime', 'required' => false, 'read-only' => true),
    );
    
    /**
     * @var array Model children
     * @todo I don't remember what this does...
     */
    protected $_children = array('attachments');

}
